﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero">

    <SolidColorBrush x:Key="DataGridBackgroundBrush" Color="Transparent" />
    <SolidColorBrush x:Key="DataGridBorderBrush" Color="White" />


    <Color x:Key="DataGridHeaderBackgroundColor">Transparent</Color>
    <Color x:Key="DataGridHeaderBackgroundMouseOverColor">#10FFFFFF</Color>
    <Color x:Key="DataGridHeaderPressedBackgroundColor">#50FFFFFF</Color>
    <Color x:Key="DataGridHeaderPressedForegroundColor">#FF000000</Color>


    <LinearGradientBrush x:Key="DataGridHeaderBackground" Opacity="0.15" StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="#FFFFFFFF" Offset="0"/>
        <GradientStop Color="#00FFFFFF" Offset="1"/>
    </LinearGradientBrush>
    <SolidColorBrush x:Key="DataGridSelectedRowBackground" Color="White" Opacity="0.15" />

    <Style x:Key="ColumnHeaderGripperStyle" TargetType="{x:Type Thumb}">
        <Setter Property="Width" Value="8"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Cursor" Value="SizeWE"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="DataGridColumnHeaderStyle" TargetType="DataGridColumnHeader">
        <Setter Property="Foreground" Value="White" />
        <Setter Property="Background" Value="{StaticResource DataGridHeaderBackground}" />
        <Setter Property="Padding" Value="5" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
                    <Grid x:Name="Grid"
                          TextBlock.Foreground="{TemplateBinding Foreground}">
                        <Grid.Background>
                            <SolidColorBrush  Color="{StaticResource DataGridHeaderBackgroundColor}" />
                        </Grid.Background>
                        <Themes:DataGridHeaderBorder BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" IsClickable="{TemplateBinding CanUserSort}" IsPressed="{TemplateBinding IsPressed}" IsHovered="{TemplateBinding IsMouseOver}" Padding="{TemplateBinding Padding}" SortDirection="{TemplateBinding SortDirection}" SeparatorBrush="{TemplateBinding SeparatorBrush}" SeparatorVisibility="{TemplateBinding SeparatorVisibility}">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <ContentPresenter Grid.Column="0" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                                <Path x:Name="SortArrow"
                                            Grid.Column="1"
                                            HorizontalAlignment="Right" VerticalAlignment="Center"
                                            Width="8" Height="6" Margin="5,0,5,0"
                                            Stretch="Fill" Opacity="1" Fill="White"
                                            RenderTransformOrigin="0.5,0.4"
                                            Visibility="Collapsed"
                                            Data="M0,0 L1,0 0.5,1 z" />
                            </Grid>
                        </Themes:DataGridHeaderBorder>
                        <Thumb x:Name="PART_LeftHeaderGripper" HorizontalAlignment="Left" Style="{StaticResource ColumnHeaderGripperStyle}"/>
                        <Thumb x:Name="PART_RightHeaderGripper" HorizontalAlignment="Right" Style="{StaticResource ColumnHeaderGripperStyle}"/>

                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.15" />
                                    <VisualTransition GeneratedDuration="0" To="Pressed" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Normal" />
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Grid.Background).(SolidColorBrush.Color)" Storyboard.TargetName="Grid">
                                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource DataGridHeaderBackgroundMouseOverColor}" />
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Grid.Background).(SolidColorBrush.Color)" Storyboard.TargetName="Grid">
                                            <EasingColorKeyFrame KeyTime="0" Value="{StaticResource DataGridHeaderPressedBackgroundColor}" />
                                        </ColorAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="SortDirection" Value="Ascending">
                            <Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
                            <Setter TargetName="SortArrow" Property="RenderTransform">
                                <Setter.Value>
                                    <RotateTransform Angle="180" />
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                        <Trigger Property="SortDirection" Value="Descending">
                            <Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
                        </Trigger>
                        
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="DataGridCellStyle" TargetType="DataGridCell">
        <Setter Property="Foreground" Value="White" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="VerticalAlignment" Value="Center" />
        <Style.Triggers>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="BorderBrush" Value="Transparent" />
                <!--<Setter Property="Background" Value="{StaticResource DataGridSelectedRowBackground}" />-->
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="DataGridRowStyle" TargetType="DataGridRow">
        <Style.Triggers>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="BorderBrush" Value="{StaticResource DataGridSelectedRowBackground}" />
                <Setter Property="Background" Value="{StaticResource DataGridSelectedRowBackground}" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="DataGrid">
        <Setter Property="AutoGenerateColumns" Value="False" />
        <Setter Property="CanUserAddRows" Value="False" />
        <Setter Property="CanUserDeleteRows" Value="False" />
        <Setter Property="CanUserResizeRows" Value="False" />
        <Setter Property="CanUserResizeColumns" Value="False" />
        <Setter Property="CanUserReorderColumns" Value="False" />
        <Setter Property="IsReadOnly" Value="True" />
        <Setter Property="Background" Value="{StaticResource DataGridBackgroundBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource DataGridBorderBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="RowHeaderWidth" Value="0" />
        <Setter Property="RowBackground" Value="{StaticResource DataGridBackgroundBrush}" />
        <Setter Property="ColumnHeaderStyle" Value="{StaticResource DataGridColumnHeaderStyle}" />
        <Setter Property="VerticalGridLinesBrush" Value="Transparent" />
        <Setter Property="HorizontalGridLinesBrush" Value="Transparent" />
        <Setter Property="CellStyle" Value="{StaticResource DataGridCellStyle}" />
        <Setter Property="RowStyle" Value="{StaticResource DataGridRowStyle}" />
    </Style>
    
</ResourceDictionary>